package com.haidechizi.leetcode;

public class _198_打家劫舍 {


    public int rob(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        return rob(0, nums);
    }

    public int rob(int i, int[] nums) {
        if (i == nums.length - 1) {
            return nums[i];
        }
        if (i == nums.length - 2) {
            return Integer.max(nums[i], nums[i + 1]);
        }
        int stole = nums[i] + rob(i + 2, nums);
        int no = rob(i + 1, nums);
        return Integer.max(stole, no);
    }


}
